KEY_YELLOW_ID = 1
KEY_BLUE_ID = 2
KEY_RED_ID = 3


# 地图上显示玩家状态
class Window_ActorStatus < Window_Base
  # 初始化
  def initialize
    super(0, 0, 160, 480)
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
  end

  # 刷新、描绘窗口
  def refresh
    self.contents.clear

    # 绘制图标
    bitmap = RPG::Cache.icon("hp")
    self.contents.blt(8, 96, bitmap, Rect.new(0, 0, 32, 32))
    bitmap = RPG::Cache.icon("atk")
    self.contents.blt(8, 128, bitmap, Rect.new(0, 0, 32, 32))
    bitmap = RPG::Cache.icon("def")
    self.contents.blt(8, 160, bitmap, Rect.new(0, 0, 32, 32))
    bitmap = RPG::Cache.icon("gold")
    self.contents.blt(8, 192, bitmap, Rect.new(0, 0, 32, 32))
    bitmap = RPG::Cache.icon("key_yellow")
    self.contents.blt(8, 224, bitmap, Rect.new(0, 0, 32, 32))
    bitmap = RPG::Cache.icon("key_blue")
    self.contents.blt(8, 256, bitmap, Rect.new(0, 0, 32, 32))
    bitmap = RPG::Cache.icon("key_red")
    self.contents.blt(8, 288, bitmap, Rect.new(0, 0, 32, 32))

    # 处理数值
    @xmapname = $game_map.name
    @xhp = $game_party.actors[0].hp
    @xatk = $game_party.actors[0].str
    @xdef = $game_party.actors[0].dex
    @xgold = $game_party.gold
    @xyellowkey = $game_party.item_number(KEY_YELLOW_ID)
    @xbluekey = $game_party.item_number(KEY_BLUE_ID)
    @xredkey = $game_party.item_number(KEY_RED_ID)

    # 描绘数值
    self.contents.font.color = normal_color
    self.contents.draw_text(16, 64, 112, 24, @xmapname)
    self.contents.draw_text(48, 96, 64, 24, @xhp.to_s, 2)
    self.contents.draw_text(48, 128, 64, 24, @xatk.to_s, 2)
    self.contents.draw_text(48, 160, 64, 24, @xdef.to_s, 2)
    self.contents.draw_text(48, 192, 64, 24, @xgold.to_s, 2)
    self.contents.draw_text(48, 224, 64, 24, @xyellowkey.to_s, 2)
    self.contents.draw_text(48, 256, 64, 24, @xbluekey.to_s, 2)
    self.contents.draw_text(48, 288, 64, 24, @xredkey.to_s, 2)
  end
end
